<!DOCTYPE html>
<html lang="zh-CN">

  <head>
  <meta charset="utf-8">
  <meta name="author" content="zchengsite, 1451426471@qq.com" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  
  
  <title>Complete list of Thales HSM commands   | EMV.COOL</title>

  
    <link rel="apple-touch-icon" href="/images/favicon.png">
    <link rel="icon" href="/images/favicon.png">
  

  <!-- Raleway-Font -->
  <link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">

  <!-- hexo site css -->
  
<link rel="stylesheet" href="/css/base.css">
<link rel="stylesheet" href="/iconfont/iconfont.css">
<link rel="stylesheet" href="/css/github-markdown.css">
<link rel="stylesheet" href="/css/highlight.css">


  <!-- jquery3.3.1 -->
  <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>

  <!-- fancybox -->
  <link href="https://cdn.bootcss.com/fancybox/3.5.2/jquery.fancybox.min.css" rel="stylesheet">
  <script async src="https://cdn.bootcss.com/fancybox/3.5.2/jquery.fancybox.min.js"></script>
  
<script src="/js/fancybox.js"></script>


  
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-144519052-1"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'UA-144519052-1');
    </script>
  

   
    <meta name="keywords" content="emv,blog,victor,victorlong,龙熙应,longxiying,emv.cool,aid,sale,void,visa,master,android,QuickChip,tag,emvtag,paypass,paywave,dpas,contact,contactless,card,pos,pin,pin-blocks,atrs,hsm,key,dukpt,3des,des,sm4,sm3,apdu,tsys,Hexo,ilovejj">
    

<meta name="generator" content="Hexo 5.3.0"><link rel="alternate" href="/atom.xml" title="EMV.COOL" type="application/atom+xml">
</head>


  <body>
    <div id="app">
      <div class="header">
  <div class="avatar">
    <a href="/">
      <!-- 头像取消懒加载，添加no-lazy -->
      
        <img src="/images/avatar.png" alt="">
      
    </a>
    <div class="nickname"><a href="/">EMV.COOL</a></div>
  </div>
  <div class="navbar">
    <ul>
      
        <li class="nav-item" data-path="/">
          <a href="/">Home</a>
        </li>
      
        <li class="nav-item" data-path="/archives/">
          <a href="/archives/">Archives</a>
        </li>
      
        <li class="nav-item" data-path="/tags/">
          <a href="/tags/">Tags</a>
        </li>
      
        <li class="nav-item" data-path="/friends/">
          <a href="/friends/">Friends</a>
        </li>
      
        <li class="nav-item" data-path="/about/">
          <a href="/about/">About</a>
        </li>
      
    </ul>
  </div>
</div>


<script src="/js/activeNav.js"></script>



      <div class="flex-container">
        <!-- 文章详情页，展示文章具体内容，url形式：https://yoursite/文章标题/ -->
<!-- 同时为「标签tag」，「朋友friend」，「分类categories」，「关于about」页面的承载页面，具体展示取决于page.type -->



  

  

  

  
  <!-- 文章内容页 url形式：https://yoursite/文章标题/ -->
  <div class="container post-details" id="post-details">
    <div class="post-content">
      <div class="post-title">Complete list of Thales HSM commands</div>
      <div class="post-attach">
        <span class="post-pubtime">
          <i class="iconfont icon-updatetime" title="Update time"></i>
          2020-12-23
        </span>
        
              <span class="post-tags">
                <i class="iconfont icon-tags" title="Tags"></i>
                
                <span class="span--tag">
                  <a href="/tags/EMV/" title="EMV">
                    <b>#</b> EMV
                  </a>
                </span>
                
              </span>
          
      </div>
      <div class="markdown-body">
        <p>List of Thales HSM commands with their description.</p>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody><tr>
<td><strong>Host Command (Response)</strong></td>
<td><strong>Function</strong></td>
<td><strong>Supported by BP-HSM</strong></td>
<td><strong>Note</strong></td>
</tr>
<tr>
<td>A0 (A1)</td>
<td>Generate a Key</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>A2 (A3, AZ)</td>
<td>Generate and Print a Component</td>
<td></td>
<td>Printer handling</td>
</tr>
<tr>
<td>A4 (A5)</td>
<td>Form a Key from Encrypted Components</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>A6 (A7)</td>
<td>Import a Key</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>A8 (A9)</td>
<td>Export a Key</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>AA (AB)</td>
<td>Translate a TMK, TPK or PVK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>AC (AD)</td>
<td>Translate a TAK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>AE (AF)</td>
<td>Translate a TMK, TPK or PVK from LMK to Another TMK, TPK or PVK</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>AG (AH)</td>
<td>Translate a TAK from LMK to TMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>AQ (AR)</td>
<td>Translate an RSA-encrypted PIN to a ZPK or TPK-encrypted</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>AS (AT)</td>
<td>Generate a CVK Pair</td>
<td></td>
<td></td>
</tr>
<tr>
<td>AU (AV)</td>
<td>Translate a CVK Pair from LMK to ZMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>AW (AX)</td>
<td>Translate a CVK Pair from ZMK to LMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>AY (AZ)</td>
<td>Translate a CVK Pair from Old LMK to New LMK Encryption</td>
<td></td>
<td></td>
</tr>
<tr>
<td>B0 (B1)</td>
<td>Translate Key Scheme</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>B2 (B3)</td>
<td>Echo Command</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>BA (BB)</td>
<td>Encrypt a Clear PIN</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>BC (BD)</td>
<td>Verify a Terminal PIN Using the Comparison Method</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>BE (BF)</td>
<td>Verify an Interchange PIN Using the Comparison Method</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>BG (BH)</td>
<td>Translate a PIN and PIN Length</td>
<td></td>
<td>Missing KEY CHANGE STORAGE</td>
</tr>
<tr>
<td>BI (BJ)</td>
<td>Generate a BDK</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>BK (BL)</td>
<td>Generate an IBM PIN Offset (of a customer selected PIN)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>BM (BN)</td>
<td>Load the Excluded PIN Table</td>
<td></td>
<td></td>
</tr>
<tr>
<td>BQ (BR)</td>
<td>Translate PIN Algorithm</td>
<td></td>
<td></td>
</tr>
<tr>
<td>BS (BT)</td>
<td>Erase the Key Change Storage</td>
<td></td>
<td></td>
</tr>
<tr>
<td>BU (BV)</td>
<td>Generate a Key Check Value</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>BW (BX)</td>
<td>Translate Keys from Old LMK to New LMK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>BY (BZ)</td>
<td>Translate ZMK from ZMK to LMK encryption</td>
<td></td>
<td></td>
</tr>
<tr>
<td>C0 (C1)</td>
<td>Generate Initial Terminal Master Keys (AS2805)</td>
<td>X</td>
<td>Term</td>
</tr>
<tr>
<td>C2 (C3)</td>
<td>Generate a MAC (Message Authentication Code, large messages) (AS2805)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>C4 (C5)</td>
<td>Verify MAC (Message Authentication Code, large messages) (AS2805)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>C6 (C7)</td>
<td>Generate a Random Number (AS2805)</td>
<td>X</td>
<td>Term</td>
</tr>
<tr>
<td>C8 (C9)</td>
<td>Generate an Acquirer Master Key Encrypting Key (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>CA (CB)</td>
<td>Translate a PIN from TPK to ZPK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>CC (CD)</td>
<td>Translate a PIN from One ZPK to Another</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>CE (CF)</td>
<td>Generate a Diebold PIN Offset</td>
<td></td>
<td></td>
</tr>
<tr>
<td>CG (CH)</td>
<td>Verify a Terminal PIN Using the Diebold Method</td>
<td>X</td>
<td>Custom Code</td>
</tr>
<tr>
<td>CI (CJ)</td>
<td>Translate a PIN from BDK to ZPK Encryption (DUKPT)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>CK (CL)</td>
<td>Verify a PIN Using the IBM Method (DUKPT)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>CM (CN)</td>
<td>Verify a PIN Using the VISA PVV Method (DUKPT)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>CO (CP)</td>
<td>Verify a PIN Using the Diebold Method (DUKPT)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>CQ (CR)</td>
<td>Verify a PIN Using the Encrypted PIN Method (DUKPT)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>CU (CV)</td>
<td>Verify &amp; Generate a VISA PVV (of a customer selected PIN)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>CW (CX)</td>
<td>Generate a Card Verification Code/Value</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>CY (CZ)</td>
<td>Verify a Card Verification Code/Value</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>D0 (D1)</td>
<td>Generate a PIN Pad Authentication Code (AS2805)</td>
<td>X</td>
<td>Term</td>
</tr>
<tr>
<td>D2 (D3)</td>
<td>Verify a PIN pad Authentication code (AS2805)</td>
<td>X</td>
<td>Term</td>
</tr>
<tr>
<td>D4 (D5)</td>
<td>Translate a PIN Block to Encryption under a PIN Encryption Key (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>D6 (D7)</td>
<td>Translate an Acquirer Master Key Encrypting Key (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>D8 (D9)</td>
<td>Encrypt a CPAT Authentication Value (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>DA (DB)</td>
<td>Verify a Terminal PIN Using the IBM Method</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>DC (DD)</td>
<td>Verify a Terminal PIN Using the VISA Method</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>DE (DF)</td>
<td>Generate an IBM PIN Offset (of an LMK encrypted PIN)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>DG (DH)</td>
<td>Generate a VISA PIN Verification Value (of an LMK encrypted PIN)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>DI (DJ)</td>
<td>Generate and Export a KML</td>
<td></td>
<td></td>
</tr>
<tr>
<td>DK (DL)</td>
<td>Import a KML</td>
<td></td>
<td></td>
</tr>
<tr>
<td>DM (DN)</td>
<td>Verify Load Signature S1 and Generate Load Signature S2</td>
<td></td>
<td></td>
</tr>
<tr>
<td>DO (DP)</td>
<td>Verify Load Completion Signature S3</td>
<td></td>
<td></td>
</tr>
<tr>
<td>DQ (DR)</td>
<td>Verify Unload Signature S1 and Generate Unload Signature S2</td>
<td></td>
<td></td>
</tr>
<tr>
<td>DS (DT)</td>
<td>Verify Unload Completion Signature S3</td>
<td></td>
<td></td>
</tr>
<tr>
<td>DU (DV)</td>
<td>Verify &amp; Generate an IBM PIN Offset (of customer selected new PIN)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>DW (DX)</td>
<td>Translate a BDK from ZMK to LMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>DY (DZ)</td>
<td>Translate a BDK from LMK to ZMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>E0 (E1)</td>
<td>Generate a KEKs Validation Request (AS2805)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>E2 (E3)</td>
<td>Generate a KEKr Validation Response (AS2805)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>E4 (E5)</td>
<td>Verify a PIN Pad Proof of End Point (POEP) (AS2805)</td>
<td>X</td>
<td>Term</td>
</tr>
<tr>
<td>E6 (E7)</td>
<td>Generate a PIN Pad Proof of Endpoint (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>E8 (E9)</td>
<td>Generate a KCA and KMACH (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>EA (EB)</td>
<td>Verify an Interchange PIN Using the IBM Method</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>EC (ED)</td>
<td>Verify an Interchange PIN Using the VISA Method</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>EE (EF)</td>
<td>Derive a PIN Using the IBM Method</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>EG (EH)</td>
<td>Verify an Interchange PIN Using the Diebold Method</td>
<td>X</td>
<td>Custom Code</td>
</tr>
<tr>
<td>EI (EJ)</td>
<td>Generate an RSA Key Set</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>EK (EL)</td>
<td>Load an RSA Secret Key</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>EM (EN)</td>
<td>Translate an RSA Secret Key</td>
<td></td>
<td></td>
</tr>
<tr>
<td>EO (EP)</td>
<td>Import a Public Key (Generate a MAC on an RSA Public Key)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>EQ (ER)</td>
<td>Validate a Public Key (Verify a MAC on an RSA Public Key)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>ES (ET)</td>
<td>Validate a Certificate and Generate a MAC on its RSA Public Key</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>EU (EV)</td>
<td>Translate a MAC on an RSA Public Key</td>
<td></td>
<td></td>
</tr>
<tr>
<td>EW (EX)</td>
<td>Generate an RSA Signature</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>EY (EZ)</td>
<td>Validate an RSA Signature</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>F0 (F1)</td>
<td>Verify a Terminal PIN using the IBM Method (AS2805)</td>
<td>X</td>
<td>Term</td>
</tr>
<tr>
<td>F2 (F3)</td>
<td>Verify a Terminal PIN using the VISA Method (AS2805)</td>
<td>X</td>
<td>Term</td>
</tr>
<tr>
<td>F4 (F5)</td>
<td>Calculate KMACI</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>F6 (F7)</td>
<td>KEKGEN (AS2805)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>F8 (F9)</td>
<td>KEKREC (AS2805)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>FA (FB)</td>
<td>Translate a ZPK from ZMK to LMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>FC (FD)</td>
<td>Translate a TMK, TPK or PVK from ZMK to LMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>FE (FF)</td>
<td>Translate a TMK, TPK or PVK from LMK to ZMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>FG (FH)</td>
<td>Generate a Pair of PVKs</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>FI (FJ)</td>
<td>Generate ZEK/ZAK</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>FK (FL)</td>
<td>Translate a ZEK/ZAK from ZMK to LMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>FM (FN)</td>
<td>Translate a ZEK/ZAK from LMK to ZMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>FO (FP)</td>
<td>Generate a Watchword Key</td>
<td></td>
<td></td>
</tr>
<tr>
<td>FQ (FR)</td>
<td>Translate a Watchword Key from LMK to ZMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>FS (FT)</td>
<td>Translate a Watchword Key from ZMK to LMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>FU (FV)</td>
<td>Verify a Watchword Response</td>
<td></td>
<td></td>
</tr>
<tr>
<td>FW (FX)</td>
<td>Generate a VISA PIN Verification Value (of a customer selected PIN)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>G0 (G1)</td>
<td>Translate a PIN from BDK to ZPK Encryption (3DES DUKPT)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>GA (GB)</td>
<td>Derive a PIN Using the Diebold Method</td>
<td></td>
<td></td>
</tr>
<tr>
<td>GC (GD)</td>
<td>Translate a ZPK from LMK to ZMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>GE (GF)</td>
<td>Translate a ZMK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>GG (GH)</td>
<td>Form a ZMK from Three ZMK Components</td>
<td></td>
<td></td>
</tr>
<tr>
<td>GI (GJ)</td>
<td>Import Key under an RSA Public Key</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>GK (GL)</td>
<td>Export Key under an RSA Public Key</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>GM (GN)</td>
<td>Hash a Block of Data</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>GO (GP)</td>
<td>Verify a PIN Using the IBM Method (3DES DUKPT)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>GQ (GR)</td>
<td>Verify a PIN Using the VISA PVV Method (3DES DUKPT)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>GS (GT)</td>
<td>Verify a PIN Using the Diebold Method (3DES DUKPT)</td>
<td>–</td>
<td></td>
</tr>
<tr>
<td>GU (GV)</td>
<td>Verify a PIN Using the Encrypted PIN Method (3DES DUKPT)</td>
<td>X</td>
<td>Custom Code</td>
</tr>
<tr>
<td>GW (GX)</td>
<td>Generate/Verify a MAC (3DES DUKPT)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>GY (GZ)</td>
<td>Form a ZMK from 2 to 9 ZMK Components</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>H0 (H1)</td>
<td>Decrypt a PIN Pad Public Key (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>H2 (H3)</td>
<td>Generate a RSA Public Key Verification Code (AS2805)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>H4 (H5)</td>
<td>Generate a KEKs for use in Node to Node interchange using RSA (AS2805)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>H6 (H7)</td>
<td>Receive a KEKr for use in Node to Node interchange using RSA (AS2805)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>H8 (H9)</td>
<td>Encrypt a Cross Acquirer Key Encrypting Key under an Initial Transport Key (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>HA (HB)</td>
<td>Generate a TAK</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>HC (HD)</td>
<td>Generate a TMK, TPK or PVK</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>I0 (I1)</td>
<td>Encrypt a Terminal Key under the Local Master Key (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>I2 (I3)</td>
<td>Import MULTOS Transport Key Certifying Key</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>I4 (I5)</td>
<td>Import MULTOS Hash Modulus Key</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>I6 (I7)</td>
<td>Translate MULTOS KTU</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>I8 (I9)</td>
<td>MULTOS ALU Generator</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>IA (IB)</td>
<td>Generate a ZPK</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>IC (ID)</td>
<td>Establish Secure Session with Chip Card</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>IE (IF)</td>
<td>Prepare Secure Message for Chip Card</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>JA (JB)</td>
<td>Generate a Random PIN</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>JC (JD)</td>
<td>Translate a PIN from TPK to LMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>JE (JF)</td>
<td>Translate a PIN from ZPK to LMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>JG (JH)</td>
<td>Translate a PIN from LMK to ZPK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>K0 (K1)</td>
<td>Verify Encrypted Counters (EMV</td>
<td></td>
<td></td>
</tr>
<tr>
<td>K2 (K3)</td>
<td>Verify Truncated Application Cryptogram (MasterCard CAP)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>K8 (K9)</td>
<td>Export a Key under a KEK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>KA (KB)</td>
<td>Generate a Key Check Value (Not Double-Length ZMK)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>KC (KD)</td>
<td>Translate a ZPK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>KE (KF)</td>
<td>Generate Issuer RSA Key Set and Public Key Certificate</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>KG (KH)</td>
<td>Validate an Issuer Public Key Certificate</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>KI (KJ)</td>
<td>Derive Card Unique DES Keys</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>KK (KL)</td>
<td>Import a Certification Authority Self-Signed Certificate</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>KM (KN)</td>
<td>Generate Static Data Authentication Signature</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>KO (KP)</td>
<td>Generate Card RSA Key Set and Public Key Certificate</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>KQ (KR)</td>
<td>ARQC Verification and/or ARPC Generation (EMV 3.1.1)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>KS (KT)</td>
<td>Data Authentication Code and Dynamic Number Verification (EMV 3.1.1)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>KU (KV)</td>
<td>Generate Secure Message (EMV 3.1.1)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>KW (KX)</td>
<td>ARQC Verification and/or ARPC Generation (EMV 4.x)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>KY (KZ)</td>
<td>Generate Secure Message (EMV 4.x)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>L0 (L1)</td>
<td>Generate an HMAC Secret Key</td>
<td></td>
<td></td>
</tr>
<tr>
<td>LA (LB)</td>
<td>Load Data to User Storage</td>
<td></td>
<td></td>
</tr>
<tr>
<td>LC (LD)</td>
<td>Verify the Diebold Table in User Storage</td>
<td></td>
<td></td>
</tr>
<tr>
<td>LE (LF)</td>
<td>Read Data from User Storage</td>
<td></td>
<td></td>
</tr>
<tr>
<td>LG (LH)</td>
<td>Set HSM Response Delay</td>
<td>X</td>
<td>Custom Code, no real functionality yet</td>
</tr>
<tr>
<td>LI (LJ)</td>
<td>Load a PIN Text String</td>
<td></td>
<td></td>
</tr>
<tr>
<td>LK (LL)</td>
<td>Generate a Decimal MAC</td>
<td></td>
<td></td>
</tr>
<tr>
<td>LM (LN)</td>
<td>Verify a Decimal MAC</td>
<td></td>
<td></td>
</tr>
<tr>
<td>LO (LP)</td>
<td>Translate Decimalisation Table from Old to New LMK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>LQ (LR)</td>
<td>Generate an HMAC on a Block of Data</td>
<td></td>
<td></td>
</tr>
<tr>
<td>LS (LT)</td>
<td>Verify an HMAC on a Block of Data</td>
<td></td>
<td></td>
</tr>
<tr>
<td>LU (LV)</td>
<td>Import an HMAC key under a ZMK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>LW (LX)</td>
<td>Export an HMAC key under a ZMK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>LY (LZ)</td>
<td>Translate a HMAC Key from Old LMK to New LMK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>M0 (M1)</td>
<td>Encrypt Data Block</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>M2 (M3)</td>
<td>Decrypt Data Block</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>M4 (M5)</td>
<td>Translate Data Block</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>M6 (M7)</td>
<td>Generate MAC</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>M8 (M9)</td>
<td>Verify MAC</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>MA (MB)</td>
<td>Generate a MAC</td>
<td></td>
<td></td>
</tr>
<tr>
<td>MC (MD)</td>
<td>Verify a MAC</td>
<td></td>
<td></td>
</tr>
<tr>
<td>ME (MF)</td>
<td>Verify and Translate a MAC</td>
<td></td>
<td></td>
</tr>
<tr>
<td>MG (MH)</td>
<td>Translate a TAK from LMK to ZMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>MI (MJ)</td>
<td>Translate a TAK from ZMK to LMK Encryption</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>MK (ML)</td>
<td>Generate a Binary MAC</td>
<td></td>
<td></td>
</tr>
<tr>
<td>MM (MN)</td>
<td>Verify a Binary MAC</td>
<td></td>
<td></td>
</tr>
<tr>
<td>MO (MP)</td>
<td>Verify and Translate a Binary MAC</td>
<td></td>
<td></td>
</tr>
<tr>
<td>MQ (MR)</td>
<td>Generate MAC (MAB) for Large Message</td>
<td></td>
<td></td>
</tr>
<tr>
<td>MS (MT)</td>
<td>Generate MAC (MAB) using ANSI X9.19 Method for a Large Message</td>
<td></td>
<td></td>
</tr>
<tr>
<td>MY (MZ)</td>
<td>Verify and Translate MAC</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>NC (ND)</td>
<td>Perform Diagnostics</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>NE (NF, NZ)</td>
<td>Generate and Print a Key as Split Components</td>
<td></td>
<td></td>
</tr>
<tr>
<td>NG (NH)</td>
<td>Decrypt an Encrypted PIN</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>NI (NJ)</td>
<td>Return Network Information</td>
<td></td>
<td></td>
</tr>
<tr>
<td>NK (NL)</td>
<td>Command Chaining</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>NO (NP)</td>
<td>HSM Status</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>NY (NZ)</td>
<td>Generate IVCVC3 and Static CVC3</td>
<td></td>
<td>EMV Issuing</td>
</tr>
<tr>
<td>OA (OB, OZ)</td>
<td>Print a PIN Solicitation Mailer</td>
<td></td>
<td></td>
</tr>
<tr>
<td>OC (OD, OZ)</td>
<td>Generate and Print a ZMK Component</td>
<td></td>
<td></td>
</tr>
<tr>
<td>OE (OF, OZ)</td>
<td>Generate and Print a TMK, TPK or PVK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>OI (OJ)</td>
<td>Generate a Set of Zone Keys (AS2805)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>OK (OL)</td>
<td>Translate a Set of Zone Keys to Encryption under the Local Master Key (AS2805)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>OU (OV)</td>
<td>Update Terminal Master Key 1 (Roll KEK 1) (AS2805)</td>
<td>X</td>
<td>Term</td>
</tr>
<tr>
<td>OW (OX)</td>
<td>Update Terminal Master Keys (Roll KEK 1 and KEK 2) (AS2805)</td>
<td>X</td>
<td>Term</td>
</tr>
<tr>
<td>P2 (P3)</td>
<td>Generate a VISA PVV (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>P4 (P5)</td>
<td>Generate a Proof of Host value (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>PA (PB)</td>
<td>Load Formatting Data to HSM</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>PC (PD)</td>
<td>Load Additional Formatting Data to HSM</td>
<td></td>
<td></td>
</tr>
<tr>
<td>PE (PF, PZ)</td>
<td>Print PIN/PIN and Solicitation Data</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>PG (PH)</td>
<td>Verify PIN/PIN and Solicitation Mailer Cryptography</td>
<td></td>
<td></td>
</tr>
<tr>
<td>PI (PJ)</td>
<td>Generate Terminal Key Set (AS2805)</td>
<td>X</td>
<td>Term</td>
</tr>
<tr>
<td>PK (PL)</td>
<td>Generate a PIN Pad Acquirer Security Number (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>PM (PN)</td>
<td>Verify a Dynamic CVV (dCVV)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>PO (PP)</td>
<td>Verify and Generate a VISA PVV, translate a PIN Block to Encryption under a Zone PIN Key (AS2805)</td>
<td>X</td>
<td>Term</td>
</tr>
<tr>
<td>PQ (PR)</td>
<td>Generate a Message Authentication Code AS2805-1988 (AS2805)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>PS (PT)</td>
<td>Validate a Message Authentication Code AS2805-1988 (AS2805)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>PU (PV)</td>
<td>Encrypt data (AS2805)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>PW (PX)</td>
<td>Decrypt data (AS2805)</td>
<td>X</td>
<td></td>
</tr>
<tr>
<td>PY (PZ)</td>
<td>Verify and Generate an IBM PIN Offset (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>Q0 (Q1)</td>
<td>Translate Audit Record MAC key</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Q2 (Q3)</td>
<td>Retrieve Audit Record</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Q4 (Q5)</td>
<td>Archive (Print) Audit Record</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Q6 (Q7)</td>
<td>Delete Audit Record</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Q8 (Q9)</td>
<td>Audit Record Verification</td>
<td></td>
<td></td>
</tr>
<tr>
<td>QA (QB)</td>
<td>Load Solicitation Data to User Storage</td>
<td></td>
<td></td>
</tr>
<tr>
<td>QC (QD)</td>
<td>Final Load of Solicitation Data to User Storage</td>
<td></td>
<td></td>
</tr>
<tr>
<td>QI (QJ)</td>
<td>Translate a PPASN from old to new LMK (AS2805)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>QM (QN)</td>
<td>Data Encryption Using a Derived Privacy Key (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>QO (QP)</td>
<td>Data Decryption Using a Derived Privacy Key (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>QQ (QR)</td>
<td>Verify a PIN at Card Issuer using IBM Method (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>QS (QT)</td>
<td>Verify a PIN at Card Issuer using the Diebold Method (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>QU (QV)</td>
<td>Verify a PIN at Card Issuer using Visa Method (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>QW (QX)</td>
<td>Verify a PIN at Card Issuer using the Comparison Method (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>RA (RB)</td>
<td>Cancel Authorised Activities</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RC (RD)</td>
<td>Verify Solicitation Mailer Cryptography</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RE (RF)</td>
<td>Verify a Transaction Request, without PIN (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>RG (RH)</td>
<td>Verify a Transaction Request, with PIN, when CD Field Available (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>RI (RJ)</td>
<td>Verify a Transaction Request, with PIN, when CD Field not Available (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>RI (RJ)</td>
<td>Transaction Request With a PIN (T/AQ Key)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RK (RL)</td>
<td>Generate Transaction Response, with Auth Para Generated by Acquirer (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>RK (RL)</td>
<td>Transaction Request Without a PIN</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RM (RN)</td>
<td>Generate Transaction Response with Auth Para Generated by Card Issuer (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>RM (RN)</td>
<td>Administration Request Message</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RO (RP)</td>
<td>Translate a PIN from PEK to ZPK Encryption (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>RO (RP)</td>
<td>Transaction Response with Auth Para from Card Issuer</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RQ (RR)</td>
<td>Verify a Transaction Completion Confirmation Request (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>RQ (RR)</td>
<td>Generate Auth Para and Transaction Response</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RS (RT)</td>
<td>Generate a Transaction Completion Response (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>RS (RT)</td>
<td>Confirmation</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RU (RV)</td>
<td>Generate Auth Para at the Card Issuer (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>RU (RV)</td>
<td>Transaction Request With a PIN (T/CI Key)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RW (RX)</td>
<td>Generate an Initial Terminal Key (AS2805.6.2)</td>
<td></td>
<td>Term</td>
</tr>
<tr>
<td>RW (RX)</td>
<td>Translate KEYVAL</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RY (RZ)</td>
<td>Calculate Card Security Codes</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RY (RZ)</td>
<td>Verify Card Security Codes</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RY (RZ)</td>
<td>Generate a CSCK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RY (RZ)</td>
<td>Export a CSCK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>RY (RZ)</td>
<td>Import a CSCK</td>
<td></td>
<td></td>
</tr>
<tr>
<td>SC (SD)</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>SE (SF)</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>SI (SJ)</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>SK (SL)</td>
<td>Generate ZAK, ZPK under BDK and MAC, PAC random numbers (Shell)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>TA (TB, TZ)</td>
<td>Print TMK Mailer</td>
<td></td>
<td></td>
</tr>
</tbody></table>

      </div>
      
        <div class="prev-or-next">
          <div class="post-foot-next">
            
              <a href="/2020/12/23/Complete-list-of-SafeNet-HSM-commands/" target="_self">
                <i class="iconfont icon-chevronleft"></i>
                <span>Prev</span>
              </a>
            
          </div>
          <div class="post-attach">
            <span class="post-pubtime">
              <i class="iconfont icon-updatetime" title="Update time"></i>
              2020-12-23
            </span>
            
                  <span class="post-tags">
                    <i class="iconfont icon-tags" title="Tags"></i>
                    
                    <span class="span--tag">
                      <a href="/tags/EMV/" title="EMV">
                        <b>#</b> EMV
                      </a>
                    </span>
                    
                  </span>
              
          </div>
          <div class="post-foot-prev">
            
              <a href="/2020/12/23/Glossary-of-Expressions-in-Payments-industry/" target="_self">
                <span>Next</span>
                <i class="iconfont icon-chevronright"></i>
              </a>
            
          </div>
        </div>
      
    </div>
    

    
      <div class="comments-container">
        




  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
  <script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>

  <div id="gitalk-container"></div>
  <script src="/js/md5.min.js"></script>
  <script>
    const gitalk = new Gitalk({
      clientID: '57cd3399b19f860fecc9',
      clientSecret: '2190b5d0de9a59b3de639f23ad0b771ead37dcca',
      repo: 'longxiying.github.io',
      owner: 'longxiying',
      admin: ['longxiying'],
      id: md5(location.pathname),
      distractionFreeMode: false
    })

    gitalk.render('gitalk-container')
  </script>


      </div>
    
  </div>


        <div class="footer">
  <div class="social">
    <ul>
      
        <li>
          <a title="github" target="_blank" rel="noopener" href="https://github.com/longxiying">
            <i class="iconfont icon-github"></i>
          </a>
        </li>
      
        <li>
          <a title="email" href="mailto:longxiying@vip.qq.com">
            <i class="iconfont icon-envelope"></i>
          </a>
        </li>
      
        <li>
          <a title="facebook" target="_blank" rel="noopener" href="https://www.facebook.com/abtswiath/">
            <i class="iconfont icon-facebooksquare"></i>
          </a>
        </li>
      
        <li>
          <a title="twitter" target="_blank" rel="noopener" href="https://twitter.com/longxiying">
            <i class="iconfont icon-twitter"></i>
          </a>
        </li>
      
        <li>
          <a title="wechat" href="">
            <i class="iconfont icon-wechat"></i>
          </a>
        </li>
      
        <li>
          <a title="weibo" target="_blank" rel="noopener" href="https://weibo.com/579081111/">
            <i class="iconfont icon-weibo"></i>
          </a>
        </li>
      
        <li>
          <a title="rss" href="/atom.xml">
            <i class="iconfont icon-rss"></i>
          </a>
        </li>
      
    </ul>
  </div>
  
    <div class="footer-more">
      
        <a href="https://emv.cool">Copyright © EMV.COOL 2020</a>
        
    </div>
  
    <div class="footer-more">
      
        <a target="_blank" rel="noopener" href="https://github.com/zchengsite/hexo-theme-oranges">Theme by Oranges | Powered by Hexo</a>
        
    </div>
  
</div>

      </div>

      <div class="back-to-top hidden">
  <a href="javascript: void(0)">
    <i class="iconfont icon-chevronup"></i>
  </a>
</div>


<script src="/js/backtotop.js"></script>



      
  <div class="search-icon" id="search-icon">
    <a href="javascript: void(0)">
      <i class="iconfont icon-search"></i>
    </a>
  </div>

  <div class="search-overlay hidden">
    <div class="search-content" tabindex="0">
      <div class="search-title">
        <span class="search-icon-input">
          <a href="javascript: void(0)">
            <i class="iconfont icon-search"></i>
          </a>
        </span>
        
          <input type="text" class="search-input" id="search-input" placeholder="Search...">
        
        <span class="search-close-icon" id="search-close-icon">
          <a href="javascript: void(0)">
            <i class="iconfont icon-close"></i>
          </a>
        </span>
      </div>
      <div class="search-result" id="search-result"></div>
    </div>
  </div>

  <script type="text/javascript">
    var inputArea = document.querySelector("#search-input")
    var searchOverlayArea = document.querySelector(".search-overlay")

    inputArea.onclick = function() {
      getSearchFile()
      this.onclick = null
    }

    inputArea.onkeydown = function() {
      if(event.keyCode == 13)
        return false
    }

    function openOrHideSearchContent() {
      let isHidden = searchOverlayArea.classList.contains('hidden')
      if (isHidden) {
        searchOverlayArea.classList.remove('hidden')
        document.body.classList.add('hidden')
        // inputArea.focus()
      } else {
        searchOverlayArea.classList.add('hidden')
        document.body.classList.remove('hidden')
      }
    }

    function blurSearchContent(e) {
      if (e.target === searchOverlayArea) {
        openOrHideSearchContent()
      }
    }

    document.querySelector("#search-icon").addEventListener("click", openOrHideSearchContent, false)
    document.querySelector("#search-close-icon").addEventListener("click", openOrHideSearchContent, false)
    searchOverlayArea.addEventListener("click", blurSearchContent, false)

    var searchFunc = function (path, search_id, content_id) {
      'use strict';
      var $input = document.getElementById(search_id);
      var $resultContent = document.getElementById(content_id);
      $resultContent.innerHTML = "<ul><span class='local-search-empty'>First search, index file loading, please wait...<span></ul>";
      $.ajax({
        // 0x01. load xml file
        url: path,
        dataType: "xml",
        success: function (xmlResponse) {
          // 0x02. parse xml file
          var datas = $("entry", xmlResponse).map(function () {
            return {
              title: $("title", this).text(),
              content: $("content", this).text(),
              url: $("url", this).text()
            };
          }).get();
          $resultContent.innerHTML = "";

          $input.addEventListener('input', function () {
            // 0x03. parse query to keywords list
            var str = '<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length <= 0) {
              return;
            }
            // 0x04. perform local searching
            datas.forEach(function (data) {
              var isMatch = true;
              var content_index = [];
              if (!data.title || data.title.trim() === '') {
                data.title = "Untitled";
              }
              var orig_data_title = data.title.trim();
              var data_title = orig_data_title.toLowerCase();
              var orig_data_content = data.content.trim().replace(/<[^>]+>/g, "");
              var data_content = orig_data_content.toLowerCase();
              var data_url = data.url;
              var index_title = -1;
              var index_content = -1;
              var first_occur = -1;
              // only match artiles with not empty contents
              if (data_content !== '') {
                keywords.forEach(function (keyword, i) {
                  index_title = data_title.indexOf(keyword);
                  index_content = data_content.indexOf(keyword);

                  if (index_title < 0 && index_content < 0) {
                    isMatch = false;
                  } else {
                    if (index_content < 0) {
                      index_content = 0;
                    }
                    if (i == 0) {
                      first_occur = index_content;
                    }
                    // content_index.push({index_content:index_content, keyword_len:keyword_len});
                  }
                });
              } else {
                isMatch = false;
              }
              // 0x05. show search results
              if (isMatch) {
                str += "<li><a href='" + data_url + "' class='search-result-title'>" + orig_data_title + "</a>";
                var content = orig_data_content;
                if (first_occur >= 0) {
                  // cut out 100 characters
                  var start = first_occur - 20;
                  var end = first_occur + 80;

                  if (start < 0) {
                    start = 0;
                  }

                  if (start == 0) {
                    end = 100;
                  }

                  if (end > content.length) {
                    end = content.length;
                  }

                  var match_content = content.substr(start, end);

                  // highlight all keywords
                  keywords.forEach(function (keyword) {
                    var regS = new RegExp(keyword, "gi");
                    match_content = match_content.replace(regS, "<span class=\"search-keyword\">" + keyword + "</span>");
                  });

                  str += "<p class=\"search-result-abstract\">" + match_content + "...</p>"
                }
                str += "</li>";
              }
            });
            str += "</ul>";
            if (str.indexOf('<li>') === -1) {
              return $resultContent.innerHTML = "<ul><span class='local-search-empty'>No result<span></ul>";
            }
            $resultContent.innerHTML = str;
          });
        },
        error: function(xhr, status, error) {
          $resultContent.innerHTML = ""
          if (xhr.status === 404) {
            $resultContent.innerHTML = "<ul><span class='local-search-empty'>The search.xml file was not found, please refer to：<a href='https://github.com/zchengsite/hexo-theme-oranges#configuration' target='_black'>configuration</a><span></ul>";
          } else {
            $resultContent.innerHTML = "<ul><span class='local-search-empty'>The request failed, Try to refresh the page or try again later.<span></ul>";
          }
        }
      });
      $(document).on('click', '#search-close-icon', function() {
        $('#search-input').val('');
        $('#search-result').html('');
      });
    }

    var getSearchFile = function() {
        var path = "/search.xml";
        searchFunc(path, 'search-input', 'search-result');
    }
  </script>




    </div>
  </body>
</html>
